function bciLoad(fileBaseName, runs, doLoadRawData, doLoadEpochData)
% bciLoad(fileBaseName, runs, doLoadRawData, doLoadEpochData,doLoadTrainData)
% reads the data of fileBaseName (absolute or relative pathname) of runs into
% global structures. Optional arguments: doLoadRawData (default 0, but required for classifier training) and
% doLoadEpochData (default 0, but requred for classifier training) 
% TODO: Comment this function in the standard format

global GLOBALbci;
global GLOBALtrainDat;

if nargin<3,
    doLoadRawData=false;
end
if nargin<4,
    doLoadEpochData=false;
end

for k=runs,
    load([fileBaseName int2str(k)]);
    GLOBALtrainDat{k} = Dat;
    if doLoadRawData,
        load([fileBaseName int2str(k) '_Rawdata']);
        GLOBALtrainDat{k}.trainDat = trainDat;
        clear trainDat
%         fid = fopen(['rawdata' int2str(k) '.dat'],'r');
%         nCh = fread(fid,1,'double');
%         GLOBALtrainDat{k}.trainDat = fread(fid,[nCh,inf],'single');
%         fclose(fid);
    end
    if doLoadEpochData,
        load([fileBaseName int2str(k) '_Epoch']);
        GLOBALtrainDat{k}.trainEpoch = double(trainEpoch);
        clear trainEpoch
    end
end
% refresh param
GLOBALbci=bciGetParam(bci);